Line | Count | Source |
1 | use uuid::Uuid; | |
2 | ||
3 | 3 | pub(crate) fn with_random_id(path: &str) -> String { |
4 | 3 | let id = Uuid::new_v4(); |
5 | ||
6 | 3 | if let Some(( |
7 | 2 | format!("{}-{}.{}", base, id, ext) |
8 | } else { | |
9 | 1 | format!("{}-{}", path, id) |
10 | } | |
11 | 3 | } |
12 | ||
13 | 5 | pub(crate) fn generate_uuid() -> Uuid { |
14 | 5 | Uuid::new_v4() |
15 | 5 | } |
16 | ||
17 | 2 | pub(crate) fn uuid_as_static_str(uuid: Uuid) -> &'static str { |
18 | 2 | Box::leak(uuid.to_string().into_boxed_str()) |
19 | 2 | } |